package com.tencet.dao.impl;

import com.tencet.dao.OpenAccountDao;
import com.tencet.entity.OpenAccount;
import com.tencet.utils.JDBCUtils;
import org.apache.commons.dbutils.QueryRunner;

import java.sql.SQLException;

/**
 * @author Yangjx
 * @version 1.0.0
 * @ClassName OpenAccountDaoImpl.java
 * @Description TODO
 * @createTime 2022年07月20日 21:04
 */
public class OpenAccountDaoImpl implements OpenAccountDao {
    QueryRunner qr = new QueryRunner();
    @Override
    public int updateAccount(OpenAccount openAccount) throws SQLException {
        //将开户数据写入数据库的openaccount表中
        String sql = "insert into openaccount (id,name,idnumber,phone,secondaccountnumber,paypassword,accounttype) values (?,?,?,?,?,?,1)";
        //返回受影响行数
        int res = qr.update(JDBCUtils.getConnection(),sql,openAccount.getId(),openAccount.getName(),openAccount.getIdNumber(),openAccount.getPhone(),openAccount.getSecondAccountNumber(),openAccount.getPayPassword());
        return res;
    }
}
